package com.winning.cqs.pregnantbabycare_cqs_v1.activity;

import com.winning.cqs.pregnantbabycare_cqs_v1.R;
import com.winning.cqs.pregnantbabycare_cqs_v1.view.TitleView;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;

public class UserSettingMoreEditActivity extends BaseActivity {

	private EditText et_phone, et_pwd, et_realname, et_borndate, et_number;
	private ImageView img_phone, img_pwd, img_realname, img_borndate,
			img_number;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_user_setting_more_edit);
		TAG = "UserSettingMoreEditActivity";
		LoadView();
		LoadData();

	}

	private void LoadData() {
		TitleView.left_back.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
		et_phone.addTextChangedListener(new TextWatcher() {

			@Override
			public void onTextChanged(CharSequence s, int start, int before,
					int count) {
				// TODO Auto-generated method stub

			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
				// TODO Auto-generated method stub

			}

			@Override
			public void afterTextChanged(Editable s) {
				// TODO Auto-generated method stub
				if (s.length() == 0) {
					img_phone.setVisibility(View.GONE);
				} else {
					img_phone.setVisibility(View.VISIBLE);
				}
			}
		});
		et_pwd.addTextChangedListener(new TextWatcher() {

			@Override
			public void onTextChanged(CharSequence s, int start, int before,
					int count) {
				// TODO Auto-generated method stub

			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
				// TODO Auto-generated method stub

			}

			@Override
			public void afterTextChanged(Editable s) {
				// TODO Auto-generated method stub
				if (s.length() == 0) {
					img_pwd.setVisibility(View.GONE);
				} else {
					img_pwd.setVisibility(View.VISIBLE);
				}
			}
		});
		et_realname.addTextChangedListener(new TextWatcher() {

			@Override
			public void onTextChanged(CharSequence s, int start, int before,
					int count) {
				// TODO Auto-generated method stub

			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
				// TODO Auto-generated method stub

			}

			@Override
			public void afterTextChanged(Editable s) {
				// TODO Auto-generated method stub
				if (s.length() == 0) {
					img_realname.setVisibility(View.GONE);
				} else {
					img_realname.setVisibility(View.VISIBLE);
				}
			}
		});
		et_borndate.addTextChangedListener(new TextWatcher() {

			@Override
			public void onTextChanged(CharSequence s, int start, int before,
					int count) {
				// TODO Auto-generated method stub

			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
				// TODO Auto-generated method stub

			}

			@Override
			public void afterTextChanged(Editable s) {
				// TODO Auto-generated method stub
				if (s.length() == 0) {
					img_borndate.setVisibility(View.GONE);
				} else {
					img_borndate.setVisibility(View.VISIBLE);
				}
			}
		});
		et_number.addTextChangedListener(new TextWatcher() {

			@Override
			public void onTextChanged(CharSequence s, int start, int before,
					int count) {
				// TODO Auto-generated method stub

			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
				// TODO Auto-generated method stub

			}

			@Override
			public void afterTextChanged(Editable s) {
				// TODO Auto-generated method stub
				if (s.length() == 0) {
					img_number.setVisibility(View.GONE);
				} else {
					img_number.setVisibility(View.VISIBLE);
				}
			}
		});
		et_phone.setSelection(et_phone.length());
	}

	private void LoadView() {
		et_phone = (EditText) findViewById(R.id.user_setting_edit_et_phone);
		et_pwd = (EditText) findViewById(R.id.user_setting_edit_et_pwd);
		et_realname = (EditText) findViewById(R.id.user_setting_edit_et_realname);
		et_borndate = (EditText) findViewById(R.id.user_setting_edit_et_borndate);
		et_number = (EditText) findViewById(R.id.user_setting_edit_et_number);
		img_phone = (ImageView) findViewById(R.id.user_setting_edit_img_phoneClearText);
		img_pwd = (ImageView) findViewById(R.id.user_setting_edit_img_pwdClearText);
		img_realname = (ImageView) findViewById(R.id.user_setting_edit_img_realnameClearText);
		img_borndate = (ImageView) findViewById(R.id.user_setting_edit_img_borndateClearText);
		img_number = (ImageView) findViewById(R.id.user_setting_edit_img_numberClearText);
	}

	public void clearPhoneText(View view) {
		et_phone.setText("");
	}

	public void clearPwdText(View view) {
		et_pwd.setText("");
	}

	public void clearRealNameText(View view) {
		et_realname.setText("");
	}

	public void clearBornDateText(View view) {
		et_borndate.setText("");
	}

	public void clearNumberText(View view) {
		et_number.setText("");
	}

}
